function arrayToTreeRec(arr) {
    let map = new Map(arr.map((node) => [node.id, { ...node, childre: [] }]));
    let tree = [];
    for (let node of Object.values(map)) {
        if (node.parent == null) {
            tree.push(node);
        } else {
            map.get(node.parent).children.push(node);
        }
    }
    return tree;
}
